package com.panshi.service.impl;

import com.panshi.mapper.AppEssayMapper;
import com.panshi.service.IAppEssayService;
import com.panshi.tools.AppEssay;
import com.panshi.tools.Check;
import com.panshi.tools.Paging;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import redis.clients.jedis.Jedis;

import java.util.List;

@Service
public class AppEssayServiceImpl implements IAppEssayService {

    @Autowired
    private AppEssayMapper appEssayMapper;

    // Redis
    Jedis jedis = new Jedis("localhost",6379);

    /**
     * 推荐 查前十条
     * @return
     */
    @Override
    public List<AppEssay> queryAppEssay(Paging paging) {

        return appEssayMapper.queryAppEssay(paging);
    }

    /***
     * 热榜 根据阅读量  降序
     * @return
     */
    @Override
    public List<AppEssay> queryAppEssayRb(int page) {
        return appEssayMapper.queryAppEssayRb(page);
    }

    /**
     * 图文热搜
     * @return
     */
    @Override
    public List<AppEssay> queryAppEssayTwRb() {
        return appEssayMapper.queryAppEssayTwRb();
    }

    /**
     * 最新  根据时间 十条 升序
     * @return
     */
    @Override
    public List<AppEssay> queryAppEssayNew(int page) {
        return appEssayMapper.queryAppEssayNew(page);
    }


    /***
     * 最新创作 根据上架时间  降序
     * @return
     */
    @Override
    public List<AppEssay> queryAppEssayNewCz(int page) {
        return appEssayMapper.queryAppEssayNewCz(page);
    }


    /***
     * 根据用户id查询所有咨询
     * @param paging
     * @return
     */
    @Override
    public  List<Check> queryAppEssayByUserId(Paging paging) {
        return appEssayMapper.queryAppEssayByUserId(paging);
    }
}
